jq(function(){
	jq.getJSON("BuyCarServlet","opr=showCar",function(data){
		alert("11");
		var contentTable=jq("#contentTable");
		var total=0;
		for(var i=0;i<data.length;i++){
		
			//////
			contentTable.append("<tr><td><div class=\"c_s_img\"><img src=\"images/c_1.jpg\" width=\"73\" height=\"73\" /></div>"+data[i].name+"</td><td align=\"center\">"+data[i].property+"</td><td align=\"center\"><div class=\"c_num\"><input type=\"button\" onclick=\"jianUpdate1(jq(this));\" class=\"car_btn_1\" /><input type=\"text\" value=\""+data[i].number+"\" name=\"\" class=\"car_ipt\" />  <input type=\"button\" onclick=\"addUpdate1(jq(this));\" class=\"car_btn_2\" /></div></td><td align=\"center\" style=\"color:#ff4e00;\">￥"+data[i].totalprice+"</td><td align=\"center\">26R</td>" +
					"<td align=\"center\"><a href=\"javascript:;\" id=\""+data[i].name+"\" class=\"delCar\" >删除</a>&nbsp; &nbsp;<a href=\"#\">加入收藏</a></td></tr>");
			///////
			total=total+data[i].totalprice
		}
		contentTable.append("<tr height=\"70\"><td colspan=\"6\" style=\"font-family:'Microsoft YaHei'; border-bottom:0;\"><label class=\"r_rad\"><input type=\"checkbox\" name=\"clear\" checked=\"checked\" /></label><label class=\"r_txt\">清空购物车</label> <span class=\"fr\">商品总价：<b style=\"font-size:22px; color:#ff4e00;\" id=\"total\">￥"+total+"</b></span> </td> </tr>")
		contentTable.append("<tr valign=\"top\" height=\"150\"><td colspan=\"6\" align=\"right\"><a href=\"#\"><img src=\"images/buy1.gif\" /></a>&nbsp; &nbsp; <a href=\"BuyCar_Two.html\"><img src=\"images/buy2.gif\" /></a> </td></tr> ");
		
	});
	
	//购物车商品
	jq.getJSON("BuyCarServlet","opr=showCar",function(data){
		var cars=jq(".cars");
		var total=0;
		for(var i=0; i<data.length;i++){
			cars.append("<li><div class=\"img\"><a href=\"#\"><img src=\"images/car1.jpg\" width=\"58\" height=\"58\" /></a></div> <div class=\"name\"><a href=\"#\">"+data[i].name+"</a></div>  <div class=\"price\"><font color=\"#ff4e00\">￥"+data[i].totalprice/data[i].number+"</font> X"+data[i].number+"</div></li>");
			total=total+data[i].totalprice
		}
		cars.append("<div class=\"price_sum\">共计&nbsp; <font color=\"#ff4e00\">￥</font><span>"+total+"</span></div>") ;
	});
	jq("#contentTable").on("click",".delCar",function(){
		var name=this.id;
		alert(name);
		jq.get("BuyCarServlet","opr=del&name="+name,function(data){
			if(data=="success"){
				location.href="BuyCar.html";
			}
		},"text")
		
		
	})
	
});